//package com.ruoyi.bigScreen;
//
//import com.ruoyi.common.core.domain.AjaxResult;
//import com.ruoyi.common.core.domain.zzw.*;
//import com.ruoyi.common.utils.RecordControllApi;
//import com.ruoyi.system.service.MeetingControlApi;
//import com.xylink.config.SDKConfigMgr;
//import com.xylink.model.*;
//import com.xylink.sdk.conferenceControl.ConferenceControlApi;
//import com.xylink.sdk.conferenceControl.CreateMeetingApi;
//import com.xylink.util.Result;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.web.bind.annotation.*;
//
//import javax.annotation.PostConstruct;
//import javax.annotation.Resource;
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//
//@RestController
//@RequestMapping("/meeting")
//@Api(tags = "小鱼易连会议管理")
//public class MeetingController {
//    static final String ENTERPRISE_ID = "ac0363b754a0afe5bd7378d81cff5e23a41ea293";
//    static final String CLIENT_ID = "222H1XyXfzI71o6wdeO1TF2m"; //
//    static final String CLIENT_SECRET = "YyUhGhVLVgTz6xdFSSYFLy2OzjaicoLV";
//    static final String API_HOST = "https://sdkapi.xylink.com";
//
//    @Resource
//    private MeetingControlApi meetingControlApi;
//
//    @Resource
//    private RecordControllApi recordControllApi;
//
//    @PostConstruct
//    public void initSDKConfig(){
//        SDKConfigMgr.initSDKConfig(API_HOST,CLIENT_ID,CLIENT_SECRET,ENTERPRISE_ID);
//    }
//
//    @ApiOperation("创建会议")
//    @GetMapping("/create")
//    public AjaxResult createMeeting() throws IOException {
//        CreateMeetingApi createMeetingApi = new CreateMeetingApi();
//        String enterpriseId = "ac0363b754a0afe5bd7378d81cff5e23a41ea293";
//        String token = "44d06c4acba341869e9b1e5e75baa2ad";
//        CreateMeetingInfo createMeetingInfo = new CreateMeetingInfo();
//        createMeetingInfo.setVersion("v1");
//        createMeetingInfo.setMeetingName("中政委大屏");
//        createMeetingInfo.setEnterpriseId(enterpriseId);
//        Result sdkMeeting = meetingControlApi.meetingCreate(createMeetingInfo);
//        return AjaxResult.success(sdkMeeting.getData());
//    }
//
//    @ApiOperation("邀请入会")
//    @GetMapping("/Invate")
//    public AjaxResult InvateMeeting(String phoneNum,String meetingNumber) throws IOException {
//        String enterpriseId = "ac0363b754a0afe5bd7378d81cff5e23a41ea293";
//        InvateInfo invateInfo = new InvateInfo();
//        invateInfo.setCallNumber(meetingNumber);

//        List<Devices> devices = new ArrayList<>();
//        String[] phoneNums = phoneNum.split(",");
//        for(String phone:phoneNums){
//            System.out.println("phone is "+phone);
//            Devices device = new Devices();
//            device.setNumber(phone);
//            devices.add(device);
//        }
//        invateInfo.setDeviceList(devices);
//        Result result = recordControllApi.invate(enterpriseId,invateInfo);
//        return AjaxResult.success(result);
//    }
//
//    @ApiOperation("获取会议状态")
//    @GetMapping("/getMeetingStatus")
//    public AjaxResult userStatus(String callNumber) throws IOException {
//        ConferenceControlApi conferenceControlApi = new ConferenceControlApi();
//        String enterpriseId = "ac0363b754a0afe5bd7378d81cff5e23a41ea293";
//        String token = "44d06c4acba341869e9b1e5e75baa2ad";
//        Result<MeetingStatus> result = conferenceControlApi.getMeetingStatus(enterpriseId,token,callNumber);
//        return AjaxResult.success(result.getData());
//    }
//
//    @ApiOperation("禁言")
//    @PostMapping("/mute")
//    public AjaxResult mute(@RequestParam String callNumber,@RequestParam boolean force,@RequestBody List<Device> devicelist) throws IOException {
//        Device[] devices = (Device[])devicelist.toArray(new Device[devicelist.size()]);
//        meetingControlApi.mute(force,callNumber,devices);
//        return AjaxResult.success();
//    }
//
//    @ApiOperation("全体禁言")
//    @GetMapping("/muteAll")
//    public AjaxResult muteAll(@RequestParam String callNumber) throws IOException {
//        String enterpriseId = "ac0363b754a0afe5bd7378d81cff5e23a41ea293";
//        String token = "44d06c4acba341869e9b1e5e75baa2ad";
//        ConferenceControlApi conferenceControlApi = new ConferenceControlApi();
//        conferenceControlApi.muteall(enterpriseId,token,callNumber);
//        return AjaxResult.success();
//    }
//
//    @ApiOperation("解除禁言")
//    @PostMapping("/unmute")
//    public AjaxResult unmute(@RequestParam String callNumber,@RequestBody List<Device> devicelist) throws IOException {
//        String enterpriseId = "ac0363b754a0afe5bd7378d81cff5e23a41ea293";
//        String token = "44d06c4acba341869e9b1e5e75baa2ad";
//        ConferenceControlApi conferenceControlApi = new ConferenceControlApi();
//        Device[] devices = (Device[])devicelist.toArray(new Device[devicelist.size()]);
//        conferenceControlApi.unmute(enterpriseId,token,callNumber,devices);
//        return AjaxResult.success();
//    }
//
//
//    @ApiOperation("踢人")
//    @PostMapping("/disconnect")
//    public AjaxResult disconnect(@RequestParam String callNumber,@RequestBody List<KickInfo> devicelist) throws IOException {
//        meetingControlApi.disconnect(callNumber,devicelist);
//        return AjaxResult.success();
//    }
//
//    @ApiOperation("设置主屏幕")
//    @PostMapping("/mainImage")
//    public AjaxResult mainImage(@RequestParam String meetingRoomNumber,@RequestBody Device device) throws IOException {
//        String enterpriseId = "ac0363b754a0afe5bd7378d81cff5e23a41ea293";
//        String token = "44d06c4acba341869e9b1e5e75baa2ad";
//        ConferenceControlApi conferenceControlApi = new ConferenceControlApi();
//        conferenceControlApi.setMainImage(enterpriseId,token,meetingRoomNumber,device);
//        return AjaxResult.success();
//    }
//
//
//
//    @ApiOperation("锁定会议")
//    @GetMapping("/lock")
//    public AjaxResult lock(@RequestParam String callNumber) throws IOException {
//        String enterpriseId = "ac0363b754a0afe5bd7378d81cff5e23a41ea293";
//        String token = "44d06c4acba341869e9b1e5e75baa2ad";
//        ConferenceControlApi conferenceControlApi = new ConferenceControlApi();
//        conferenceControlApi.meetingLock(enterpriseId,token,callNumber);
//        return AjaxResult.success();
//    }
//
//    @ApiOperation("解锁会议")
//    @GetMapping("/unlock")
//    public AjaxResult unlock(@RequestParam String callNumber) throws IOException {
//        String enterpriseId = "ac0363b754a0afe5bd7378d81cff5e23a41ea293";
//        String token = "44d06c4acba341869e9b1e5e75baa2ad";
//        ConferenceControlApi conferenceControlApi = new ConferenceControlApi();
//        conferenceControlApi.meetingUnlock(enterpriseId,token,callNumber);
//        return AjaxResult.success();
//    }
//
//    @ApiOperation("会议状态回调")
//    @PostMapping("/ConferenceRosterInfo")
//    public void ConferenceRosterInfo(@RequestBody XyResponse xyResponse)  {
//        Map<String,Object>  ConferenceRosterInfo = (Map<String, Object>) xyResponse.getData();
//        System.out.println("--------> ConferenceRosterInfo is :" + ConferenceRosterInfo);
//    }
//
//    @ApiOperation("出入会回调")
//    @PostMapping("/NewUserCall")
//    public void NewUserCall(@RequestBody XyResponse xyResponse){
//        Map<String,Object>  newUserCall = (Map<String, Object>) xyResponse.getData();
//        System.out.println("--------> newUserCall is :" + newUserCall);
//    }
//
//    @ApiOperation("删除云会议室")
//    @GetMapping("/delete")
//    public AjaxResult  MeetingDelete(String callNumber) throws IOException {
//
//        Result result = meetingControlApi.MeetingDelete(ENTERPRISE_ID,callNumber);
//        return AjaxResult.success(result);
//    }
//
//    @ApiOperation("结束会议")
//    @GetMapping("/stop")
//    public AjaxResult  MeetingStop(String callNumber) throws IOException {
//
//        Result result = meetingControlApi.MeetingStop(callNumber);
//        return AjaxResult.success();
//    }
//
//    @GetMapping("/meetingQuery")
//    public AjaxResult meetingQuery() throws IOException {
//        return AjaxResult.success(meetingControlApi.meetingQuery());
//    }
//
//    @ApiOperation("结束会议")
//    @GetMapping("/end")
//    public AjaxResult  MeetingEnd(String callNumber) throws IOException {
//
//        Result result1 = meetingControlApi.MeetingStop(callNumber);
//        if(result1.isSuccess()){
//            Result result = meetingControlApi.MeetingDelete(ENTERPRISE_ID,callNumber);
//            if(result.isSuccess()){
//                return AjaxResult.success(result);
//            }
//        }
//        return AjaxResult.error("结束会议异常，请检查重新删除会议："+callNumber);
//    }
//
//    @ApiOperation("关闭摄像头")
//    @PostMapping("/closeCamera")
//    public AjaxResult closeCamera(@RequestBody CloseInfo closeInfo) throws IOException {
//        Result result = meetingControlApi.closeCamera(closeInfo);
//        return AjaxResult.success();
//    }
//
//    @GetMapping("/meetingHostSet")
//    public AjaxResult meetingHostSet() throws IOException {
//        MeetingSet meetingSet = new MeetingSet();
//        Device device = new Device();
//        device.setId(245208431);
//        device.setType(17);
//        device.setParticipantNumber("18253094236");
//        meetingSet.setAction("set");
//        meetingSet.setDevice(device);
//        return AjaxResult.success(meetingControlApi.meetingHostSet(meetingSet));
//    }
//
//    @PostMapping("/signNotify")
//    public void signNotify(SignNotify signNotify){
//        System.out.println(signNotify.toString());
//    }
//
//
//
//}
